#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar(); 
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e6 + 10;
const int inf = 0x7fffffff;

int n,K,L;
int a[N],b[N],stu[N];
ll ans;
priority_queue < pii > q[6];

void clear() {
	for(int i = 0;i < 6;i++) while(q[i].size()) q[i].pop();
	for(int i = 0;i <= n;i++) stu[i] = 0; ans = 0;
}

void add0(int x) { stu[x] = 0; q[0].push({a[x] + b[x],x}); }
void add1(int x) { stu[x] = 1; q[1].push({-a[x],x}); q[2].push({b[x],x}); }
void add2(int x) { stu[x] = 2; q[3].push({-b[x],x}); q[4].push({a[x],x}); }
void add3(int x) { stu[x] = 3; q[5].push({-a[x] - b[x],x}); }

ll get0() { while(q[0].size() && stu[q[0].top().se] != 0) q[0].pop(); if(q[0].size()) return q[0].top().fi; return -inf; }
ll get1() { while(q[1].size() && stu[q[1].top().se] != 1) q[1].pop(); if(q[1].size()) return q[1].top().fi; return -inf; }
ll get2() { while(q[2].size() && stu[q[2].top().se] != 1) q[2].pop(); if(q[2].size()) return q[2].top().fi; return -inf; }
ll get3() { while(q[3].size() && stu[q[3].top().se] != 2) q[3].pop(); if(q[3].size()) return q[3].top().fi; return -inf; }
ll get4() { while(q[4].size() && stu[q[4].top().se] != 2) q[4].pop(); if(q[4].size()) return q[4].top().fi; return -inf; }
ll get5() { while(q[5].size() && stu[q[5].top().se] != 3) q[5].pop(); if(q[5].size()) return q[5].top().fi; return -inf; }

void turn0() { int x = q[0].top().se; add3(x); }
void turn1() { int x = q[1].top().se; add0(x); }
void turn2() { int x = q[2].top().se; add3(x); }
void turn3() { int x = q[3].top().se; add0(x); }
void turn4() { int x = q[4].top().se; add3(x); }
void turn5() { int x = q[5].top().se; add0(x); }

void add(int st,int i) { if(st == 0) add0(i); if(st == 1) add1(i); if(st == 2) add2(i); if(st == 3) add3(i); }

void solve() {
	n = in,K = in,L = in; for(int i = 1;i <= n;i++) a[i] = in; for(int i = 1;i <= n;i++) b[i] = in;
	vector < pii > t; for(int i = 1;i <= n;i++) t.pb({a[i],i}); sort(t.begin(),t.end(),greater < pii > ());
	for(int i = 0;i < K;i++) ans += t[i].fi,stu[t[i].se] = 1;
	vector < pii > td; t.swap(td); for(int i = 1;i <= n;i++) t.pb({b[i],i}); sort(t.begin(),t.end(),greater < pii > ());
	for(int i = 0;i < K;i++) ans += t[i].fi,stu[t[i].se] |= 2; int cur = 0;
	for(int i = 1;i <= n;i++) add(stu[i],i),cur += (stu[i] == 3);
	while(cur < L) {
		ll c1 = get0() + get1() + get3(), c2 = get2() + get3(), c3 = get4() + get1(), c4 = get2() + get4() + get5();
		ll mn = max(c1,c2); mn = max(mn,c3); mn = max(c4,mn); ans += mn;
		if(mn == c1) turn0(), turn1(), turn3(); else if(mn == c2) turn2(),turn3();
		else if(mn == c3) turn4(),turn1(); else if(mn == c4) turn2(),turn4(),turn5(); cur++;
	}
	printf("%lld\n",ans);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("sequence.in","r",stdin); freopen("sequence.out","w",stdout);
#endif
	for(int T = in;T;T--) solve(),clear();
	return 0;
}
